package function;

import java.util.ArrayList;
import java.util.Scanner;

import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import windows.Win;

public class SystemManager {
	
	public final static Scanner consoleInput = new Scanner(System.in);
	private static ArrayList<Win> backgroundWin = new ArrayList<Win>();
	private volatile static Win runInMainWin = null;
	
//	public SystemManager() {
//		this.container = new JPanel();
//		this.container.setFocusable( true );
//	}
	
	public static void addBackgroundWin(Win window) {
		backgroundWin.add(window);
	}
	
	public static Win getLastBackgroundWin() {
		
		Win lastWin = backgroundWin.get(backgroundWin.size()-1);
		backgroundWin.remove(backgroundWin.size()-1);
		
		return lastWin;
	}
	
	public static void stopKeyListen() {
		try {
			GlobalScreen.unregisterNativeHook();
		} catch (NativeHookException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void startKeyListen() {
		try {
			GlobalScreen.registerNativeHook();
		} catch (NativeHookException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static Win getRunInMainWin() {
		return runInMainWin;
	}

	public static void setRunInMainWin(Win runInMainWin) {
		SystemManager.runInMainWin = runInMainWin;
	}
}
